home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Steal This CD
/
steal_this_cd.iso
/
Chapter 07 - Where the Hackers Are
/
virc200.exe
/
{app}
/
Scripts
/
winamp.vsc
< prev
Wrap
Text File
|
2003-05-16
|
14KB
|
495 lines
// Winamp control for ViRC 2.0pre11
// Jesse McGrew (Mr2001) <jmcgrew@hansprestige.com>
//
// Changes for pre11:
// Added Winamp control toolbar with song display. Edit the configuration
// section of this file to alter the appearance of the toolbar.
// Clicking on a prev, play, pause, stop, or next button while holding
// the control or shift key will have the same effect as control- or shift-
// clicking in Winamp.
// To use this script, add it to the "add-on scripts" list in ViRC's
// configuration.
// You must have Winamp running before using these commands:
// /z - announce current song title, position, and quality
// /zv - announce winamp version, client version, and winamp.vsc version
// /zp - go to previous song in playlist
// /zn - go to next song in playlist
// /zz - pause/unpause
// /zj - play/restart
// /zk - stop
// /zl - load
// /zlu - load URL
// /zld - load directory
//-------------------------------------------------------------------
// CONFIGURATION:
// $WA_TB_Enabled - Show the Winamp toolbar? (0/1)
@ $WA_TB_Enabled = 1
// $WA_TB_WinTypes - Show the toolbar for these window types:
// (virc,servers,channels,queries,chats,whiteboards)
@ $WA_TB_WinTypes = virc
// $WA_TB_Buttons - Show these items in the toolbar:
// (prev play pause stop next load saysong sayversion timedisplay songdisplay)
@ $WA_TB_Buttons = prev play pause stop next load timedisplay songdisplay
// $WA_TB_TimeDisplayType - Show time display in this format:
// 1 - track elapsed time
// 2 - track remaining time
@ $WA_TB_TimeDisplayType = 1
// $WA_TB_SongDisplayType - Show song display in this format:
// 1 - artist
// 2 - title
// 3 - artist - title
// 4 - title - artist
@ $WA_TB_SongDisplayType = 3
//-------------------------------------------------------------------
// API constants: converted from Nullsoft's FRONTEND.H
// (see http://www.winamp.com/nsdn/winamp2x/dev/sdk/FRONTEND.H)
@ $WM_COMMAND = 273
@ $WM_COPYDATA = 74
// WM_WA_IPC messages
@ $WM_WA_IPC = 1024
@ $IPC_GETVERSION = 0
@ $IPC_DELETE = 101
@ $IPC_STARTPLAY = 102
@ $IPC_ISPLAYING = 104
@ $IPC_GETOUTPUTTIME = 105
@ $IPC_JUMPTOTIME = 106
@ $IPC_WRITEPLAYLIST = 120
@ $IPC_SETPLAYLISTPOS = 121
@ $IPC_SETVOLUME = 122
@ $IPC_SETPANNING = 123
@ $IPC_GETLISTLENGTH = 124
@ $IPC_SETSKIN = 200
@ $IPC_GETSKIN = 201
@ $IPC_EXECPLUG = 202
@ $IPC_GETPLAYLISTFILE = 211
@ $IPC_GETPLAYLISTTITLE = 212
@ $IPC_GETLISTPOS = 125
@ $IPC_GETINFO = 126
@ $IPC_GETEQDATA = 127
@ $IPC_SETEQDATA = 128
@ $IPC_ADDBOOKMARK = 129
@ $IPC_RESTARTWINAMP = 135
@ $IPC_MBOPEN = 241
@ $IPC_INETAVAILABLE = 242
@ $IPC_UPDTITLE = 243
@ $IPC_CHANGECURRENTFILE = 245
@ $IPC_GETMBURL = 246
@ $IPC_REFRESHPLCACHE = 247
@ $IPC_MBBLOCK = 248
@ $IPC_MBOPENREAL = 249
@ $IPC_GET_SHUFFLE = 250
@ $IPC_GET_REPEAT = 251
@ $IPC_SET_SHUFFLE = 252
@ $IPC_SET_REPEAT = 253
// WM_COPYDATA messages
@ $IPC_PLAYFILE = 100
@ $IPC_CHDIR = 103
// WM_COMMAND messages
@ $WINAMP_OPTIONS_EQ = 40036
@ $WINAMP_OPTIONS_PLEDIT = 40040
@ $WINAMP_VOLUMEUP = 40058
@ $WINAMP_VOLUMEDOWN = 40059
@ $WINAMP_FFWD5S = 40060
@ $WINAMP_REW5S = 40061
// prev
@ $WINAMP_BUTTON1 = 40044
// play
@ $WINAMP_BUTTON2 = 40045
// pause
@ $WINAMP_BUTTON3 = 40046
// stop
@ $WINAMP_BUTTON4 = 40047
// next
@ $WINAMP_BUTTON5 = 40048
// shift+prev = scan back
@ $WINAMP_BUTTON1_SHIFT = 40144
// shift+play = open file
@ $WINAMP_BUTTON2_SHIFT = 40145
// shift+pause = no effect
@ $WINAMP_BUTTON3_SHIFT = 40146
// shift+stop = fade out
@ $WINAMP_BUTTON4_SHIFT = 40147
// shift_next = scan forward
@ $WINAMP_BUTTON5_SHIFT = 40148
// ctrl+prev = first
@ $WINAMP_BUTTON1_CTRL = 40154
// ctrl+play = open URL
@ $WINAMP_BUTTON2_CTRL = 40155
// ctrl+pause = no effect
@ $WINAMP_BUTTON3_CTRL = 40156
// ctrl+stop = no effect
@ $WINAMP_BUTTON4_CTRL = 40157
// ctrl+next = last
@ $WINAMP_BUTTON5_CTRL = 40158
// eject
@ $WINAMP_FILE_PLAY = 40029
// ctrl+eject
@ $WINAMP_FILE_PLAY_URL = 40185
// shift+eject
@ $WINAMP_FILE_PLAY_DIR = 40187
@ $WINAMP_OPTIONS_PREFS = 40012
@ $WINAMP_OPTIONS_AOT = 40019
@ $WINAMP_HELP_ABOUT = 40041
// Functions
Alias WA_GETVERSION
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $nver = $SendMessage($hwnd $WM_WA_IPC 0 $IPC_GETVERSION)
@l $hi = $($nver >> 8)
@l $lo = $($nver & 255)
// SDK docs say winamp 2 returns the version as $20yx for version 2.yx,
// but it seems to return $2y0x...
@ $fresult = $($hi / 16).$($hi % 16)$($lo % 16)
endif
EndAlias
Alias WA_GETPOSITION
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $curms = $SendMessage($hwnd $WM_WA_IPC 0 $IPC_GETOUTPUTTIME)
@l $cursec = $($curms / 1000)
@ $fresult = $($cursec / 60):
if ($cursec % 60 < 10)
@ $fresult = ${fresult}0$($cursec % 60)
else
@ $fresult = $fresult$($cursec % 60)
endif
@l $totalsec = $SendMessage($hwnd $WM_WA_IPC 1 $IPC_GETOUTPUTTIME)
if ($totalsec > 0)
@ $fresult = $fresult/$($totalsec / 60):
if ($totalsec % 60 < 10)
@ $fresult = ${fresult}0$($totalsec % 60)
else
@ $fresult = $fresult$($totalsec % 60)
endif
endif
endif
EndAlias
Alias WA_GETINFO
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $samplerate = $SendMessage($hwnd $WM_WA_IPC 0 $IPC_GETINFO)
@l $bitrate = $SendMessage($hwnd $WM_WA_IPC 1 $IPC_GETINFO)
@l $channels = $SendMessage($hwnd $WM_WA_IPC 2 $IPC_GETINFO)
@ $fresult = $samplerate kHz, $bitrate kbps,
switch $channels
case 1:
@ $fresult = $fresult mono
case 2:
@ $fresult = $fresult stereo
case else
@ $fresult = $fresult ${channels}ch
endswitch
endif
EndAlias
Alias WA_GETTITLE
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $text = $GetWindowText($hwnd)
@ $fresult = $strtokrex(". " $strtoklex(" - Winamp" $GetWindowText($hwnd)))
endif
EndAlias
Alias WA_RUNNING
@l $hwnd = $FindWindow("Winamp v1.x")
@ $fresult = $($hwnd != 0)
EndAlias
// Commands
Alias Z
if $WA_Running()
Me is listening to \b[\b$WA_GetTitle()\b]\b at $WA_GetPosition() ($WA_GetInfo())
endif
EndAlias
Alias ZV
if $WA_Running()
Me is using Winamp $WA_GetVersion(), ViRC $ver, winamp.vsc 1.00
endif
EndAlias
Alias ZN
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_BUTTON5 0
endif
^MTimer 100 1 Z
EndAlias
Alias ZP
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_BUTTON1 0
endif
^MTimer 100 1 Z
EndAlias
Alias ZZ
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_BUTTON3 0
endif
EndAlias
Alias ZJ
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_BUTTON2 0
endif
EndAlias
Alias ZK
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_BUTTON4 0
endif
EndAlias
Alias ZL
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_FILE_PLAY 0
endif
EndAlias
Alias ZLU
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_FILE_PLAY_URL 0
endif
EndAlias
Alias ZLD
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
SendMessage $hwnd $WM_COMMAND $WINAMP_FILE_PLAY_DIR 0
endif
EndAlias
// Toolbar
if ($WA_TB_Enabled)
@l $TS = $new(TStringList)
foreach ($i; $listunique($WA_TB_Buttons))
// (prev play pause stop next load saysong sayversion timedisplay songdisplay)
switch $i
case prev:
$TS.Add T_PREV 0 "tb_wa_prev.bmp" | Previous
case play:
$TS.Add T_PLAY 0 "tb_wa_play.bmp" | Play/restart
case pause:
$TS.Add T_PAUSE 0 "tb_wa_pause.bmp" | Pause/unpause
case stop:
$TS.Add T_STOP 0 "tb_wa_stop.bmp" | Stop
case next:
$TS.Add T_NEXT 0 "tb_wa_next.bmp" | Next
case load:
$TS.Add T_LOAD 0 "tb_wa_load.bmp" | Load
case saysong:
$TS.Add T_SAYSONG 0 Song | Say song name
case sayversion:
$TS.Add T_SAYVERSION 0 Ver | Say version information
case timedisplay:
$TS.Add T_TIMEDISPLAY 4 | Time display
OnServer 0 ^MTimer wa_tb_timedisplay 500 0 _wa_tb_timedisplay
case songdisplay:
$TS.Add T_SONGDISPLAY 4 | Song display
OnServer 0 ^Timer wa_tb_songdisplay 3 0 _wa_tb_songdisplay
endswitch
endforeach
$TS.SaveToToolbar TB_WINAMP "Winamp control" for $WA_TB_WinTypes docked top order last
Destroy $TS
endif
Alias _WA_TB_SENDMSG
// _wa_tb_sendmsg <plain> <shift> <ctrl>
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $sk = $ShiftKeys()
if ($isinset([shift] $sk))
SendMessage $hwnd $WM_COMMAND $2 0
else if ($isinset([ctrl] $sk))
SendMessage $hwnd $WM_COMMAND $3 0
else
SendMessage $hwnd $WM_COMMAND $1 0
endif
endif
EndAlias
ToolbarItem T_PREV on TB_WINAMP
_wa_tb_sendmsg $WINAMP_BUTTON1 $WINAMP_BUTTON1_SHIFT $WINAMP_BUTTON1_CTRL
_wa_tb_songdisplay
EndToolbarItem
ToolbarItem T_PLAY on TB_WINAMP
_wa_tb_sendmsg $WINAMP_BUTTON2 $WINAMP_BUTTON2_SHIFT $WINAMP_BUTTON2_CTRL
EndToolbarItem
ToolbarItem T_PAUSE on TB_WINAMP
_wa_tb_sendmsg $WINAMP_BUTTON3 $WINAMP_BUTTON3_SHIFT $WINAMP_BUTTON3_CTRL
EndToolbarItem
ToolbarItem T_STOP on TB_WINAMP
_wa_tb_sendmsg $WINAMP_BUTTON4 $WINAMP_BUTTON4_SHIFT $WINAMP_BUTTON4_CTRL
EndToolbarItem
ToolbarItem T_NEXT on TB_WINAMP
_wa_tb_sendmsg $WINAMP_BUTTON5 $WINAMP_BUTTON5_SHIFT $WINAMP_BUTTON5_CTRL
_wa_tb_songdisplay
EndToolbarItem
ToolbarItem T_LOAD on TB_WINAMP
_wa_tb_sendmsg $WINAMP_FILE_PLAY $WINAMP_FILE_PLAY_DIR $WINAMP_FILE_PLAY_URL
EndToolbarItem
ToolbarItem T_SAYSONG on TB_WINAMP
Z
EndToolbarItem
ToolbarItem T_SAYVERSION on TB_WINAMP
ZV
EndToolbarItem
Event <OnCreateWindow_winamp_tb> "*"
@l $obj = $maptoolbar($1:TB_WINAMP)
Halt if $obj == -1
UnmapObject $obj
// time display
@l $obj = $maptoolbar($1:TB_WINAMP:T_TIMEDISPLAY)
if ($obj != -1)
@p $obj.Width = 40
@p $obj.ReadOnly = True
UnmapObject $obj
endif
// song display
@l $obj = $maptoolbar($1:TB_WINAMP:T_SONGDISPLAY)
if ($obj != -1)
@p $obj.Width = 250
@p $obj.ReadOnly = True
UnmapObject $obj
endif
EndEvent
Event <OnStart_winamp_tb> "*"
FireEvent <OnCreateWindow_winamp_tb> TMainForm !Main
EndEvent
Alias _WA_TB_TIMEDISPLAY
if ([$1] == [])
// loop over servers, dcc chats, and whiteboards
@l $hwnd = $FindWindow("Winamp v1.x")
if ($hwnd)
@l $curms = $SendMessage($hwnd $WM_WA_IPC 0 $IPC_GETOUTPUTTIME)
if ($WA_TB_TimeDisplayType == 2)
// remaining time
@l $totalms = $SendMessage($hwnd $WM_WA_IPC 1 $IPC_GETOUTPUTTIME)
@l $dispms = $($totalms - $curms)
else
@l $dispms = $curms
endif
@l $sec = $($dispms / 1000)
@l $min = $($sec / 60)
@l $sec = $($sec % 60)
if ($sec < 10)
@l $sec = 0$sec
endif
if ($WA_TB_TimeDisplayTime == 2)
// remaining time
@l $time = -$min:$sec
else
@l $time = $min:$sec
endif
else
@l $time = ?
endif
// update main form
SetToolbar !Main:TB_WINAMP T_TIMEDISPLAY.Caption = $time
// loop over servers
@l $cnt = $listelementcount($serverlist())
for (@l $i = 1; $i < $cnt; $i++)
OnServer $i _wa_tb_timedisplay $time
endfor
// loop over dcc chats and whiteboards
foreach ($i; $dccchatlist())
SetToolbar $i:TB_WINAMP T_TIMEDISPLAY.Caption = $time
endforeach
foreach ($i; $whiteboardlist())
SetToolbar $i:TB_WINAMP T_TIMEDISPLAY.Caption = $time
endforeach
else
// update server
SetToolbar .:TB_WINAMP T_TIMEDISPLAY.Caption = $1
// loop over channels and queries
foreach ($i; $channellist())
SetToolbar $i:TB_WINAMP T_TIMEDISPLAY.Caption = $1
endforeach
foreach ($i; $querylist())
SetToolbar $i:TB_WINAMP T_TIMEDISPLAY.Caption = $1
endforeach
endif
EndAlias
Alias _WA_TB_SONGDISPLAY
if ([$1-] == [])
// loop over servers, dcc chats, and whiteboards
@l $title = $WA_GetTitle()
if ([$title] == []) || ([$title] == [<no value>])
@l $title = ?
endif
// update main form
SetToolbar !Main:TB_WINAMP T_SONGDISPLAY.Caption = $title
// loop over servers
@l $cnt = $listelementcount($serverlist())
for (@l $i = 1; $i < $cnt; $i++)
OnServer $i _wa_tb_songdisplay $title
endfor
// loop over dcc chats and whiteboards
foreach ($i; $dccchatlist())
SetToolbar $i:TB_WINAMP T_SONGDISPLAY.Caption = $title
endforeach
foreach ($i; $whiteboardlist())
SetToolbar $i:TB_WINAMP T_SONGDISPLAY.Caption = $title
endforeach
else
// update server
SetToolbar .:TB_WINAMP T_SONGDISPLAY.Caption = $1-
// loop over channels and queries
foreach ($i; $channellist())
SetToolbar $i:TB_WINAMP T_SONGDISPLAY.Caption = $1-
endforeach
foreach ($i; $querylist())
SetToolbar $i:TB_WINAMP T_SONGDISPLAY.Caption = $1-
endforeach
endif
EndAlias